Skip to content

Comments

Implement exporting profile to single template string.#95

Merged
RisaDev merged 5 commits intoAether-Tools:mainfrom
MBadea21:main
Feb 22, 2026
Merged

Implement exporting profile to single template string.#95
RisaDev merged 5 commits intoAether-Tools:mainfrom
MBadea21:main

Conversation

@MBadea21
Copy link
Contributor

useful for compressing multiple templates into just one

uses IPCCharacterProfile similar to how PCP handling uses it to compress to one templat

For issue #89

useful for compressing multiple templates into just one

uses IPCCharacterProfile similar to how PCP handling uses it to compress to one template
@MBadea21
Copy link
Contributor Author

Built and tested locally.

Doesn't change anything, simply adds workaround for this issue leveraging already existing methods.

Also used windows clipboard for parity with template export to string, can change both together to IMGUI clipboard together.

@RisaDev
Copy link
Member

RisaDev commented Feb 21, 2026

Hi, thank you for your contribution. If imgui's clipboard functionality doesn't have any known issues then it would be great if you could replace all of the current winforms-based implementation of clipboard import/export with that so we no longer need to reference windows-specific code.

@RisaDev RisaDev added the enhancement New feature or request label Feb 21, 2026
@MBadea21 MBadea21 marked this pull request as draft February 22, 2026 16:41
@MBadea21
Copy link
Contributor Author

MBadea21 commented Feb 22, 2026

Having a look over at how Glamoure does this, OtterGui has this class to wrap the ImGui Clipboard functions,

using Dalamud.Bindings.ImGui;
using OtterGui.Text.HelperObjects;

namespace OtterGui.Text;

public static partial class ImUtf8
{
    /// <summary> Copy the given text to the clipboard. </summary>
    /// <param name="text"> The text as a UTF8 string. HAS to be null-terminated. </param>
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void SetClipboardText(ReadOnlySpan<byte> text)
        => ImGui.SetClipboardText(text);

    /// <param name="text"> The given text as a UTF16 string. </param>
    /// <inheritdoc cref="SetClipboardText(ReadOnlySpan{byte})"/>
    /// <exception cref="ImUtf8FormatException" />
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void SetClipboardText(ref Utf8StringHandler<TextStringHandlerBuffer> text)
        => SetClipboardText(text.Span());

    /// <param name="text"> The given text as a formatted string. </param>
    /// <inheritdoc cref="SetClipboardText(ReadOnlySpan{char})"/>
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void SetClipboardText(ReadOnlySpan<char> text)
        => SetClipboardText(text.Span<TextStringHandlerBuffer>());


    /// <summary> Obtain the current text from the clipboard. </summary>
    /// <returns> An owned, null-terminated span of UTF8 text. An empty (still null-terminated) span on failure. </returns>
    public static TerminatedByteString GetClipboardTextUtf8()
    {
        var ptr = ImGui.GetClipboardTextU8();
        return ptr.Length is 0
            ? TerminatedByteString.Empty
            : ptr.CloneNullTerminated();
    }

    /// <inheritdoc cref="GetClipboardTextUtf8"/>
    /// <returns> A string of the current clipboard text. An empty string on failure. </returns>
    public static string GetClipboardText()
        => ImGui.GetClipboardText();
}

Would you like me to use these instead? Currently, template export to clipboard uses ImGui dirrectly.

@RisaDev
Copy link
Member

RisaDev commented Feb 22, 2026

Yea, copying the way glamourer/penumbra does things is always preferred. Just make sure you are not copying the code from OtterGui into C+, just update the submodule if it's too old and use those functions directly from there.

@MBadea21
Copy link
Contributor Author

just checked, the submodule is up to date with the repo, so will just update all to use the wrapper class.

…instead of calling System.Windows.Forms / ImGui clipboard functions directly
…instead of calling System.Windows.Forms / ImGui clipboard functions directly, change tooltip on button to be more clear that it's about exporting a template
…ystem.Windows.Forms clipboard functions.

fix popup window size on "You have unsaved changes in the current template", as the keep editing button was being cut off
…d crashes when using the file browser, and my visual studio is not showing whats used and not that well currently properly
@MBadea21
Copy link
Contributor Author

When changing template import/export and profile export to use wrapper ass i also found out that the functionality to copy / import bone groups is a thing (lmao) and that it uses ImGui clipboard.

image

Should I change this to also use the OtterGUI clipboard wrapper?

Besides that, a lot of debug functions use ImGUI directly, but I think those can just keep using it directly, altough it's up to you.

@RisaDev
Copy link
Member

RisaDev commented Feb 22, 2026

Should I change this to also use the OtterGUI clipboard wrapper?

Yea, let's do that.

Besides that, a lot of debug functions use ImGUI directly, but I think those can just keep using it directly, altough it's up to you.

You you feel like you can improve something and got some time for that - feel free to do that!

@MBadea21
Copy link
Contributor Author

Should I change this to also use the OtterGUI clipboard wrapper?

That should be all done now.

Regarding the debug functions, the wrapper is pretty minimal, handling both text span directly or UTF8Stringhandler objects as the parameter, so I doubt there is much value swapping the debug copy to clipboard functions to use the wrapper instead.

Also, I did notice that the "You have unsaved changes in current template" menu doesnt is not big enough for all 4 buttons, i just adjusted the W scale of it to be fine. As it's based on Viewport Width, im assuming on ultrawide its fine, but on 16:9 it the "Keep editing" button was cut off, while as now, all buttons are visible fine even on 16:9

image

As the main goal of the PR is all done and tested fine, I'll mark this as ready for review.

I do wanna say that due to me being new to using Visual Studio, I kept the import statements as for some reason it's having trouble displaying to me if the imports are still in use, and I was getting some crashes when accessing some file selection stuff with the "using System.Windows.Forms" statement removed even though it compiles fine.

@MBadea21 MBadea21 marked this pull request as ready for review February 22, 2026 18:48
@RisaDev
Copy link
Member

RisaDev commented Feb 22, 2026

Also, I did notice that the "You have unsaved changes in current template" menu doesnt is not big enough for all 4 buttons, i just adjusted the W scale of it to be fine. As it's based on Viewport Width, im assuming on ultrawide its fine, but on 16:9 it the "Keep editing" button was cut off, while as now, all buttons are visible fine even on 16:9

I would advise against adjusting that without testing it on various resolutions because windows like this aren't being properly dynamically adjusted to the resolution right now and you might end up breaking it for a lot of people.

@RisaDev
Copy link
Member

RisaDev commented Feb 22, 2026

Anyway the code seems to be more or less fine so I'll merge it and adjust a bit.

If you'll be willing to test the window width change with multiple resolutions - feel free to make a new PR for it, for now I'll revert that change.

Thanks for your contribution!

@RisaDev RisaDev merged commit ecc888c into Aether-Tools:main Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants